主题
发送字符串IME - SendStringIme
函数简介
向当前绑定窗口发送文本(IME 组合结果)。必须配合 BindWindowEx 的通用模式 dx.public.input.ime 使用。
无独立 hwnd 参数,目标固定为当前绑定窗口。需要指定窗口、安装/卸载 IME 通道,或在 Bind 前预装通道时,请用 SendStringIme2。
接口名称
SendStringImeDLL调用
int SendStringIme(long ola, string str);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| str | 字符串 | 要发送的文本。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
int ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if (ret == 1) {
ola.SendStringIme("你好");
ola.UnBindWindow();
}
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0)
{
int ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if (ret == 1)
{
ola.SendStringIme("你好");
ola.UnBindWindow();
}
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
hwnd = ola.FindWindow("", "记事本")
if hwnd != 0:
ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0)
if ret == 1:
ola.SendStringIme("你好")
ola.UnBindWindow()java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
int ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if (ret == 1) {
ola.SendStringIme("你好");
ola.UnBindWindow();
}
}go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
hwnd := ola.FindWindow("", "记事本")
if hwnd != 0 {
ret := ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0)
if ret == 1 {
ola.SendStringIme("你好")
ola.UnBindWindow()
}
}rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let hwnd = ola.find_window("", "记事本");
if hwnd != 0 {
let ret = ola.bind_window_ex(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if ret == 1 {
ola.send_string_ime("你好");
ola.un_bind_window();
}
}cpp
var ola = com("OlaPlug.OlaSoft")
var hwnd = ola.FindWindow("", "记事本")
if(hwnd) {
var ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0)
if(ret == 1) {
ola.SendStringIme("你好")
ola.UnBindWindow()
}
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
hwnd = ola.FindWindow("", "记事本")
If hwnd <> 0 Then
ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0)
If ret = 1 Then
ola.SendStringIme("你好")
ola.UnBindWindow
End If
End Iftext
.局部变量 ola, OLAPlug
.局部变量 hwnd, 长整数型
.局部变量 ret, 整数型
ola.创建 ()
hwnd = ola.FindWindow ("", “记事本”)
.如果真 (hwnd ≠ 0)
ret = ola.BindWindowEx (hwnd, “dx”, “windows”, “windows”, “dx.public.input.ime”, 0)
.如果真 (ret = 1)
ola.SendStringIme (“你好”)
ola.UnBindWindow ()
.如果真结束
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var hwnd = ola.FindWindow("", "记事本");
if(hwnd){
var ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if(ret == 1){
ola.SendStringIme("你好");
ola.UnBindWindow();
}
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 hwnd = ola.FindWindow("", "记事本")
如果真 (hwnd ≠ 0)
整数 ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0)
如果真 (ret = 1)
ola.SendStringIme("你好")
ola.UnBindWindow()
结束
结束cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int64_t hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
int32_t ret = ola.BindWindowEx(hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
if (ret == 1) {
ola.SendStringIme("你好");
ola.UnBindWindow();
}
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
BindWindowEx(instance, hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
SendStringIme(instance, "你好");csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int BindWindowEx(long ola, long hwnd, string display, string mouse, string keyboard, string pub, int mode);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SendStringIme(long ola, string str);
long instance = CreateCOLAPlugInterFace();
BindWindowEx(instance, hwnd, "dx", "windows", "windows", "dx.public.input.ime", 0);
SendStringIme(instance, "你好");python
from ctypes import CDLL, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.BindWindowEx(instance, hwnd, b"dx", b"windows", b"windows", b"dx.public.input.ime", 0)
ola.SendStringIme(instance, "你好".encode("utf-8"))返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 绑定前置 | 必须先 BindWindowEx,且 public 含 dx.public.input.ime。仅 BindWindow 或未带该标志时本接口无效。 |
| 目标窗口 | 无 hwnd 参数,始终发给当前绑定窗口。 |
| 与 SendStringIme2 | 需要指定 hwnd、或安装/卸载 IME 通道(mode=200/300)时用 SendStringIme2。 |
| 与 SendString | SendString / SendString2 走消息/整串插入,不依赖 IME 通道。 |
